<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<title>问题详情</title>
	    <%@include file="/common/commonCSS.jsp" %>
	    <%@include file="/common/commonJS.jsp" %>
		<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
	</head>
	<body >
		<div class="main-container" id="main-container">
			<form class="form-horizontal  bv-form" id="knowledgeForm">
				<div style="display: none">
					<input id="id" name="id"  value="${knowledge.id}"/>
				</div>
				<div class="row">
					<div class="form-group col-xs-12 ">
						<label class="col-xs-3 control-label no-padding-right"><i class="red"> * </i>标题:</label>
						<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<input id="topic" name="topic" type="text" datatype="*1-64" class="form-control" value="${knowledge.topic}" required="required"/>
							</span>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-xs-12 ">
						<label class="col-xs-3 control-label no-padding-right"><i class="red"> * </i>关键字:</label>
						<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<input id="keyWord" name="keyWord" type="text" datatype="*1-64" class="form-control" value="${knowledge.keyWord}" required="required"/>
							</span>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-xs-12 ">
						<label class="col-xs-3 control-label no-padding-right"><i class="red"> * </i>解决方案:</label>
						<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<textarea id="solution" name="solution" datatype="*1-500" class="form-control" rows="3">${knowledge.solution}</textarea>
							</span>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-xs-12">
						<label class="col-xs-3 control-label no-padding-right"><i class="red"> * </i>业务系统:</label>
						<div class="col-xs-9">
							<div class="col-xs-9">
								<input  id="operationName" datatype="*" nullmsg="业务系统不能为空!" onclick="selectBus()" placeholder="请选择业务系统" name="operationName" readonly type="text" class="form-control" value="${knowledge.operationName}"/>
								<input  style="display:none" id="operation" datatype="*" nullmsg="业务不能为空!" onclick="selectBus()" placeholder="请选择业务" name="operation" readonly type="text" class="form-control" value="${knowledge.operation}"/>
							</div>
							<div class="col-xs-3">
								<button type="button" class="layui-btn layui-btn-small" onclick="selectBus()">选择 <i class="layui-icon">&#xe61a;</i></button>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-xs-12 ">
						<label class="col-sm-3 control-label no-padding-right"><i class="red"> * </i>类型:</label>
						<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<%--<tag:select nameKey="pro_priority" name="priority" clazz="form-control"/>--%>
								<tag:select nameKey="knowledge_type" name="type" clazz="form-control" isAddDefaltOption="true" defaltOptionValue="--请选择--" initSelectedKey="${knowledge.type}"/>
							</span>
						</div>
					</div>
				</div>
				<%--<div class="row">--%>
					<%--<div class="form-group col-xs-12 ">--%>
						<%--<label class="col-sm-3 control-label no-padding-right"><i class="red"> * </i>问题原因分类:</label>--%>
						<%--<div class="col-xs-9">--%>
							<%--<span class="col-xs-11 block input-icon input-icon-right">--%>
								<%--<tag:select nameKey="pro_reason" name="reason" clazz="form-control" isAddDefaltOption="true" defaltOptionValue="--请选择--" initSelectedKey="${knowledge.reason}"/>--%>
							<%--</span>--%>
						<%--</div>--%>
					<%--</div>--%>
				<%--</div>--%>
				<%--<div class="row">--%>
					<%--<div class="form-group col-xs-12 ">--%>
						<%--<div class="block">--%>
							<%--<span class="demonstration">默认</span>--%>
							<%--<el-date-picker--%>
									<%--v-model="value1"--%>
									<%--type="datetime"--%>
									<%--placeholder="选择日期时间">--%>
							<%--</el-date-picker>--%>
						<%--</div>--%>
					<%--</div>--%>
				<%--</div>--%>
				<c:forEach items="${fieldList}" var="firld" varStatus="i">
					<div class="row">
						<div class="form-group col-xs-12 ">
							<label class="col-xs-3 control-label no-padding-right"><c:if test="${firld.flagRequired==true}" ><i class="red"> * </i></c:if>${firld.fieldName}:</label>
							<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<input  name="valueDictionarys[${i.index}].fieldId" type="hidden" value="${firld.id}"/>
								 <c:if test="${firld.fieldType == '1'}">
									 <input  name="valueDictionarys[${i.index}].fieldValue"  <c:if test="${firld.flagRequired==true}" >datatype="*1-64"</c:if>$type="text" class="form-control" value="<c:forEach items="${knowledge.valueDictionarys}" var="valueDictionary"><c:if test="${firld.id == valueDictionary.fieldId}">${valueDictionary.fieldValue}</c:if></c:forEach>"/>
								 </c:if>
								 <c:if test="${firld.fieldType == '2'}">
									 <textarea  name="valueDictionarys[${i.index}].fieldValue"  <c:if test="${firld.flagRequired==true}" > datatype="*1-500" </c:if>class="form-control" rows="3"><c:forEach items="${knowledge.valueDictionarys}" var="valueDictionary"><c:if test="${firld.id == valueDictionary.fieldId}">${valueDictionary.fieldValue}</c:if></c:forEach></textarea>

								 </c:if>
							</span>
							</div>
						</div>
					</div>

				</c:forEach>
				<div class="row" style="margin-left: 40%;padding-bottom: 28px;margin-top: 25px;">
					<button class="layui-btn" type="button" id="submitBtn">保 存</button>
					<a class="layui-btn layui-btn-normal" href="${webRoot}/knowledge/list">返 回</a>
				</div>
			</form>
		</div>
	</body>
	<div style="display: none;padding:10px;" id="operationTree">
		<span>业务树:</span>
		<ul name="operationTree" class="ztree"></ul>
	</div>
	<script>
        var setting = {
            view: {dblClickExpand: false}
            ,data: {key: {name:"name"},simpleData: {enable: true,idKey: "id",pIdKey: "parentId"}}
            ,callback: {}
        };
        var ztree;
        $(function(){
            var data='${operationTree}';
            ztree=$.fn.zTree.init($("ul[name='operationTree']"), setting, eval(''+data+''));//ztree树加载
        });

        //选择业务弹框
        function selectBus() {
            var modelId='${model.operationList.id}';
            if(modelId !=''){
                alertMsg("保存后,就不能修改了");
            }else {
                layer.open({
                    type: 1,
                    offset: '0px',
                    skin: 'layui-layer-molv',
                    title: "选择业务系统",
                    area: ['250px', '350px'],
                    shade: 0,
                    shadeClose: false,
                    content: $("#operationTree"),
                    btn: ['确定', '取消'],
                    btn1: function (index) {
                        var node = ztree.getSelectedNodes();
                        if(node[0].type == '2'){
                            alertMsg("只能选择业务类，不能选择分组!");
                            return;
                        }
                        //选择上级菜单
                        $("#operation").val(node[0].id);
                        $("#operationName").val(node[0].name);
                        layer.close(index);
                    }
                });
            }
        }
		//提交
		$("#submitBtn").click(function () {
			var url ="${webRoot}/knowledge/edit";
            checkFormValid($("#knowledgeForm"),function () {
                $.post(url,$("#knowledgeForm").serialize(),function (result) {
                    if(result.code == '0'){
                        if($("#id").val() == ''){
                            alert(result,function () {
                                location.href='${webRoot}/knowledge/list';
                            },function () {
                                $("#submitBtn").reset();
                            });
                        }else {
                            //更新成功，返回List页面
                            toast(result.msg);
                            location.href='${webRoot}/knowledge/list';
                        }
                    }else {
                        alertMsg(result.msg);
                    }

                });
            });

		});
	</script>
</html>